package com.ricky;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * Created by baiguantao on 2017/10/25.
 */
@SpringBootApplication
@EnableEurekaClient
@RestController
public class EurekaclientApplication {

    private static Logger log = LoggerFactory.getLogger(EurekaclientApplication.class);
    @GetMapping(value = "/greeting")
    public String greet() {
        log.info("client1:Access /greeting");

        List<String> greetings = Arrays.asList("Hi there", "Greetings", "Salutations");
        Random rand = new Random();

        int randomNum = rand.nextInt(greetings.size());
        return greetings.get(randomNum);
    }
    public static void main(String[] args) {
        SpringApplication.run(EurekaclientApplication.class, args);
    }
}
